From: Carlos Soriano Date: Fri, 14 Feb 2014 17:39:32 +0000 (+0100) Subject: messageTray: Add source actor without count label X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2763 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=598f7508591c1ba039e4086f43c40cdb9e8d6a53;p=gnome-shell.git messageTray: Add source actor without count label Split the current implementation of SourceActor into SourceActor and SourceActorWithLabel. In this manner we can use source actors withouth count labels, required in the screenShield to not clash with the count text label. https://bugzilla.gnome.org/show_bug.cgi?id=709275 --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 53e838eb4..68a22576d 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1162,32 +1162,12 @@ const SourceActor = new Lang.Class({ })); this._actorDestroyed = false; - this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER, - x_expand: true, - y_align: Clutter.ActorAlign.CENTER, - y_expand: true }); - - this._counterBin = new St.Bin({ style_class: 'summary-source-counter', - child: this._counterLabel, - layout_manager: new Clutter.BinLayout() }); - this._counterBin.hide(); - - this._counterBin.connect('style-changed', Lang.bind(this, function() { - let themeNode = this._counterBin.get_theme_node(); - this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x'); - this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y'); - })); - this._iconBin = new St.Bin({ width: size, height: size, x_fill: true, y_fill: true }); this.actor.add_actor(this._iconBin); - this.actor.add_actor(this._counterBin); - - this._source.connect('count-updated', Lang.bind(this, this._updateCount)); - this._updateCount(); this._source.connect('icon-updated', Lang.bind(this, this._updateIcon)); this._updateIcon(); @@ -1211,6 +1191,48 @@ const SourceActor = new Lang.Class({ _allocate: function(actor, box, flags) { // the iconBin should fill our entire box this._iconBin.allocate(box, flags); + }, + + _updateIcon: function() { + if (this._actorDestroyed) + return; + + if (!this._iconSet) + this._iconBin.child = this._source.createIcon(this._size); + } +}); + +const SourceActorWithLabel = new Lang.Class({ + Name: 'SourceActorWithLabel', + Extends: SourceActor, + + _init: function(source, size) { + this.parent(source, size); + + this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER, + x_expand: true, + y_align: Clutter.ActorAlign.CENTER, + y_expand: true }); + + this._counterBin = new St.Bin({ style_class: 'summary-source-counter', + child: this._counterLabel, + layout_manager: new Clutter.BinLayout() }); + this._counterBin.hide(); + + this._counterBin.connect('style-changed', Lang.bind(this, function() { + let themeNode = this._counterBin.get_theme_node(); + this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x'); + this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y'); + })); + + this.actor.add_actor(this._counterBin); + + this._source.connect('count-updated', Lang.bind(this, this._updateCount)); + this._updateCount(); + }, + + _allocate: function(actor, box, flags) { + this.parent(actor, box, flags); let childBox = new Clutter.ActorBox(); @@ -1233,14 +1255,6 @@ const SourceActor = new Lang.Class({ this._counterBin.allocate(childBox, flags); }, - _updateIcon: function() { - if (this._actorDestroyed) - return; - - if (!this._iconSet) - this._iconBin.child = this._source.createIcon(this._size); - }, - _updateCount: function() { if (this._actorDestroyed) return; @@ -1353,7 +1367,7 @@ const Source = new Lang.Class({ if (this._mainIcon) return; - this._mainIcon = new SourceActor(this, this.SOURCE_ICON_SIZE); + this._mainIcon = new SourceActorWithLabel(this, this.SOURCE_ICON_SIZE); }, // Unlike createIcon, this always returns the same actor;